use single_thread_final::{build_response, Response};

#[test]
fn build_response_serializes_struct_to_http_string() {
    let response = Response {
        status_line: "HTTP/1.1 200 OK".into(),
        headers: vec![("Content-Length".into(), "5".into())],
        body: "Hello".into(),
    };

    assert_eq!(
        build_response(response),
        "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nHello"
    );
}

#[test]
fn build_response_allows_empty_headers() {
    let response = Response {
        status_line: "HTTP/1.1 404 NOT FOUND".into(),
        headers: vec![],
        body: "Not Found".into(),
    };

    assert_eq!(
        build_response(response),
        "HTTP/1.1 404 NOT FOUND\r\n\r\nNot Found"
    );
}